package cst.a113cx.recyclerview02;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.OrientationHelper;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {


    private RecyclerView recyclerView;
   // private List<String> mDatas;
    private MyRecyclerAdapter2 recycleAdapter;

    private ArrayList<Abean> data00=new ArrayList<Abean>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        recyclerView = (RecyclerView) findViewById(R.id.recv );

        //initData();
        showmine();
        recycleAdapter= new MyRecyclerAdapter2(MainActivity.this ,data00);

        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        //设置布局管理器
        recyclerView.setLayoutManager(layoutManager);
        //设置为垂直布局，这也是默认的
        layoutManager.setOrientation(OrientationHelper.VERTICAL);
        //设置Adapter
        recyclerView.setAdapter( recycleAdapter);
        //设置增加或删除条目的动画
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

//    private void initData() {
//        mDatas = new ArrayList<String>();
//        for ( int i=0; i < 40; i++) {
//            mDatas.add( "item"+i);
//        }
//    }

    private void showmine(){
        for(int i=0;i<=5;i++){
            Abean temp=new Abean();
            temp.buildone(i+1,"标题"+i,i,"描述"+i);
            temp.setImgid(R.drawable.f1+i);

            data00.add(temp);
        }


    }

}
